package com.example.amazing_wangjj.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.example.amazing_wangjj.assiatant.AmazingWJJ;
import com.example.amazing_wangjj.pojo.UserChat;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@Tag(name = "神奇JJ", description = "神奇JJ的接口")
@RestController
@RequestMapping("/amazingwjj")
//@CrossOrigin // 允许跨域
public class UserChatController {
    @Autowired
    private AmazingWJJ amazingWJJ;

    //knife4j的接口文档，需要在application.yml中配置swagger的相关信息
    @Operation(summary = "对话")

    //使用流式web输出
    @PostMapping(value="/chat", produces = "text/stream;charset=UTF-8")
    public Flux<String> chat(@RequestBody UserChat userChat)  {
        return amazingWJJ.chat(userChat.getMemoryId(), userChat.getMessage());
    }

}
